/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package camera;

import UserInterface.SetCameras;
import com.googlecode.javacv.FrameGrabber;
import com.googlecode.javacv.FrameGrabber.Exception;
import com.googlecode.javacv.VideoInputFrameGrabber;

/**
 *
 * @author Home
 */
public class Discovering extends Thread {

    private int CameraNo;
    private boolean active = true;

    public Discovering(int CameraNo) {
        this.CameraNo = CameraNo;
    }

    @Override
    public void run() {
        try {
            FrameGrabber grabber = new VideoInputFrameGrabber(CameraNo);
            Thread.sleep(1000);
            grabber.start();
            Thread.sleep(1000);
            while (active) {
                try {
                    SetCameras.setimfromcam(grabber.grab(), CameraNo);
                } catch (Exception ex) {
                }
            }
            grabber.stop();


        } catch (InterruptedException ex) {
        } catch (Exception ex) {
        }
    }

    /**
     * @param active the active to set
     */
    public void setActive(boolean active) {
        this.active = active;
    }
}
